/**
 * 打开文档
 * @param {string} input value
 * @returns {number} output value
 */
export function openFile(filePath) {
	uni.showLoading({
		title: '加载中'
	})
	uni.downloadFile({
		url: filePath,
		success: function(res) {
			var filePath = res.tempFilePath
			uni.openDocument({
				filePath: encodeURI(filePath),
				success: function(res) {
					uni.hideLoading()
				},
				fail: function(err) {
					uni.hideLoading()
					uni.showToast({
						title: '打开失败',
						duration: 1500,
						icon: 'none'
					})
				}
			})
		},
		fail: function(err) {
			uni.hideLoading()
			setTimeout(() => {
				uni.showToast({
					title: '下载失败',
					duration: 1500,
					icon: 'none'
				})
			}, 1500)
		}
	})
}